//
//  MPStoreKit.h
//  MissPaparazzi
//
//  Created by Alexey Aleshkov on 16.09.12.
//  Copyright (c) 2012 DzeTech. All rights reserved.
//


#import <Foundation/Foundation.h>
#import <StoreKit/StoreKit.h>


typedef void(^MPStoreKitRestoreTransactionsSuccessBlock)(NSArray *productIdentifiers);
typedef void(^MPStoreKitRestoreTransactionsProgressBlock)(NSString *productIdentifier);
typedef void(^MPStoreKitRestoreTransactionsFailureBlock)(NSError *error);

typedef void(^MPStoreKitBuyFeatureSuccessBlock)(NSString *productIdentifier);
typedef void(^MPStoreKitBuyFeatureFailureBlock)(NSString *productIdentifier, NSError *error);

typedef void(^MPStoreKitProductsRequestSuccessBlock)(NSArray *products, NSArray *invalidProductIdentifiers);
typedef void(^MPStoreKitProductsRequestFailureBlock)(NSError *error);


@interface MPStoreKit : NSObject <SKPaymentTransactionObserver>
{
	NSMutableArray *_restoreTransactionBlocks;
	NSMutableDictionary *_productIdentifiers;
	NSRecursiveLock *_lock;
}

+ (MPStoreKit *)sharedInstance;

- (void)requestProductsWithProductIdentifiers:(NSArray *)productIdentifiers successBlock:(MPStoreKitProductsRequestSuccessBlock)successBlock failureBlock:(MPStoreKitProductsRequestFailureBlock)failureBlock;

- (void)buyFeature:(NSString *)productIdentifier successBlock:(MPStoreKitBuyFeatureSuccessBlock)successBlock failureBlock:(MPStoreKitBuyFeatureFailureBlock)failureBlock;

- (void)restoreTransactionsWithSuccessBlock:(MPStoreKitRestoreTransactionsSuccessBlock)successBlock progressBlock:(MPStoreKitRestoreTransactionsProgressBlock)progressBlock failureBlock:(MPStoreKitRestoreTransactionsFailureBlock)failureBlock;

@end
